package com.tencent.wxcloudrun.utils;


import cn.hutool.crypto.digest.DigestUtil;

import java.util.UUID;

public class PasswordUtil {

    // 生成盐值
    public static String generateSalt() {
        return UUID.randomUUID().toString().replace("-", "").substring(0, 8);
    }

    // 加密密码
    public static String hashPassword(String password, String salt) {
        return DigestUtil.sha256Hex(password + salt);
    }

    // 验证密码
    public static boolean verifyPassword(String inputPassword, String hashedPassword, String salt) {
        return hashPassword(inputPassword, salt).equals(hashedPassword);
    }


}
